﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GameType.aspx.cs" Inherits="Jy123.Web.Manage.GameType" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>管理比赛类型</title>
    <link href="css/custom/jquery.ui.css" rel="stylesheet" type="text/css" />
    <link href="css/main.css" rel="stylesheet" type="text/css" />

    <script src="js/jquery.js" type="text/javascript"></script>

    <script src="js/jquery.ui.js" type="text/javascript"></script>

    <script src="js/main.js" type="text/javascript"></script>

    <script type="text/javascript" language="javascript">
    function Validate(){ 
        var fileUpload=document.getElementById('<%=fileUpload.ClientID %>');
        var actionHidden=document.getElementById('<%=actionTypeHidden.ClientID %>');
        var button=document.getElementById('<%=SaveButton.ClientID %>');
        button.disabled="";        
        if(fileUpload.value==''){        
            if(actionHidden.value=='Add'){
                $("#noLogoSpan").css('display','block');
                $("#errorLogoSpan").css('display','none');
                button.disabled="disabled";
                return false;
            }
        }else{
            $("#noLogoSpan").css('display','none');
           var fileName=fileUpload.value;
           var index=fileName.lastIndexOf(".")+1;
           var length=fileName.length-fileName.lastIndexOf(".")-1;                                                  
           var fileType=fileName.substr(index,length);           
           if(fileType=='jpg'||fileType=='gif'||fileType=='tiff'||fileType=='jpeg'||fileType=='png'||fileType=='bmp'){
                $("#errorLogoSpan").css('display','none');
                $("#gameImg").attr("src",fileUpload.value);        
           }else{
                $("#errorLogoSpan").css('display','block');
                button.disabled="disabled";
                return false; 
           }          
        }
      }
    </script>

</head>
<body>
    <h4>
        <a href="#"><span>比赛类型管理</span></a></h4>
    <form id="manageJTypeForm" runat="server">
    <div class="register">
        <h5>
            比赛类型名称
        </h5>
        <ul>
            <li>
                <asp:TextBox ID="gameNameTextBox" runat="server" MaxLength="20" CssClass="text" onblur="Validate()"></asp:TextBox></li>
            <li>
                <asp:RequiredFieldValidator ID="gameNameRequired" CssClass="warning" runat="server"
                    ControlToValidate="gameNameTextBox" ErrorMessage="请填写比赛类型名称" Display="Dynamic"
                    ForeColor=""></asp:RequiredFieldValidator>
            </li>
        </ul>
        <h5>
            比赛类型图标
        </h5>
        <ul>
            <li>
                <asp:FileUpload ID="fileUpload" CssClass="text" runat="server" onchange="Validate()" />
            </li>
            <li><img id="gameImg" alt="比赛类型图" class="listImg" /> (36*36)</li>
            <li><span id="noLogoSpan" class="warning1" style="display: none;">请上传一张图片</span></li>
            <li><span id="errorLogoSpan" class="warning1" style="display: none;">请选择正确的图片格式</span></li>
        </ul>
        <ul class="bb">
            <li>
                <asp:HiddenField ID="actionTypeHidden" runat="server" Value="Add" />
                <asp:HiddenField ID="idHidden" runat="server" />
                <asp:Button ID="SaveButton" runat="server" CssClass="button" Text="保存" OnClick="Save" />
            </li>
        </ul>
    </div>
    <asp:Repeater ID="gameTypeRepeater" runat="server" Visible="false" OnItemDataBound="Repeater_DataBound"
        OnItemCommand="Repeater_Command">
        <HeaderTemplate>
            <table class="tblist">
                <tr>
                    <th>
                        比赛类型
                    </th>
                    <th>
                        比赛类型图标
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td>
                    <asp:HiddenField ID="idHidden" runat="server" />
                    <asp:Label ID="gameNameLabel" runat="server"></asp:Label>
                </td>
                <td>
                    <img id="gameTypeImage" src="" class="listImg" alt="" runat="server" />
                </td>
                <td>
                    <asp:LinkButton ID="EditButton" runat="server" CssClass="btnsty" CausesValidation="false"
                        CommandName="Edit" Text="修改" />
                    <asp:LinkButton ID="DeleteButton" runat="server" CssClass="btnsty cred" CausesValidation="false"
                        CommandName="Delete" Text="删除" OnClientClick="return confirm('确定删除？')" />
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>
    </form>
</body>
</html>
